﻿CREATE FUNCTION [util].[GetDurationFromInt]
(@Duration INT)
RETURNS VARCHAR (50)
AS
BEGIN
	DECLARE @DurationChar char(6)
	SET @DurationChar = RIGHT('000000' + CAST(@Duration AS varchar(6)),6)
	
	DECLARE @ReturnValue varchar(50)
	SET @ReturnValue = CAST(CAST(LEFT(@DurationChar,2) AS int) AS varchar) + ' hours, '
		+ CAST(CAST(SUBSTRING(@DurationChar,3,2) AS int) AS varchar) + ' minutes, '
		+ CAST(CAST(RIGHT(@DurationChar,2) AS int) AS varchar) + ' seconds'
	
	RETURN @ReturnValue
END